/*
*	Animator.java -  Part of BrowserChooser 0.2
*
*	OpenSource code and fragments by avocado systems, Marcus Fuhrmeister
*
*	Redistribution and use in source and binary forms, with or without
*	modification, are permitted provided that the following conditions
*	are met:
*  
*		* Redistribution of source code must retain the above OpenSource comment,
*		this list of conditions and the following disclaimer.
* 
*		* Redistribution in binary form must reproduce the above OpenSource comment,
*		this list of conditions and the following disclaimer in the
*		documentation and/or other materials provided with the distribution.
* 
*	Neither the name of 'avocaod systems, Marcus Fuhrmeister' or the
*	names of contributors may be used to endorse or promote products derived
*	from this software without specific prior written permission.
*
*   This program is free software; you can redistribute it and/or modify
*   it under the terms of the GNU General Public License as published by
*   the Free Software Foundation; either version 2 of the License, or
*   (at your option) any later version.
*
*   This program is distributed in the hope that it will be useful,
*   but WITHOUT ANY WARRANTY; without even the implied warranty of
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*   GNU General Public License for more details.
*
*   You should have received a copy of the GNU General Public License
*   along with this program; if not, write to the Free Software
*	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
*
*	@project	BrowserChooser 0.2
*	@package	de.fuhrmeister.browserchooser.animation
*	@file		Animator.java
*
*/
package de.fuhrmeister.browserchooser.animation;

import java.awt.EventQueue;

import javax.swing.JFrame;

/**
 *  
 *	@date		09.12.2009
 *	@author		Marcus Fuhrmeister
 *  @version
 */

public class Animator {

	public static final int ANIMATE_WIDTH_ENLARGE = 0x000001;
	public static final int ANIMATE_WIDTH_SHRINK = 0x000002;
	public static final int ANIMATE_HEIGHT_ENLARGE = 0x000003;
	public static final int ANIMATE_HEIGHT_SHRINK = 0x000004;
	public static final int ANIMATE_COMPONENTS_ENLARGE = 0x000010;
	public static final int ANIMATE_COMPONENTS_SHRINK = 0x000011;
	
	private static RAnimatorSize runnable;
	static boolean isAnimating = false;

	public static void setAnimation(final int animation, JFrame window, final int value) {
		switch (animation) {
		case (Animator.ANIMATE_WIDTH_ENLARGE): {
			runnable = new RAnimatorSize(window, value, 1);
			break;
		}
		case (Animator.ANIMATE_WIDTH_SHRINK): {
			runnable = new RAnimatorSize(window, value, -1);
			break;
		}
		}
	}

	public static void start(final int speed, final int delay) {
		runnable.setSpeed(speed);
		runnable.setDelay(delay);
		EventQueue.invokeLater(runnable);
		//Thread thread = new Thread(runnable);
		//thread.start();
	}

	public static boolean isAnimating() {
		return Animator.isAnimating;
	}
}
